<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/artDialog.js?skin=simple'); ?>"></script>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/plugins/iframeTools.js'); ?>"></script>
<link type="text/css" rel="stylesheet" href="<?php echo $this->basePath('public/css/dbblack/css/ucenter.css'); ?>" />

<div class="container clearfix">
    <?php echo $this->partial('shopfront/home/left_menu.phtml'); ?>
    <div class="uc-content">
        <h1 class="title"><span><?php echo $this->translate('我的订单'); ?>：</span></h1>
        <div class="box list-item order-status">
            <div class="title"><b><?php echo $this->translate('订单号'); ?>：</b><?php echo $this->order_info->order_sn; ?><b><?php echo $this->translate('下单日期'); ?>：</b><?php echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分')."s".$this->translate('秒'), $this->order_info->order_time); ?> <b><?php echo $this->translate('状态'); ?>：</b>
                <?php echo $this->frontwebsite()->getOneOrderStateInfo($this->order_info->order_state); ?>
                <?php if ($this->order_info->order_state == 10) { ?>
                    &nbsp;<a href="<?php echo $this->url('frontorder/default/order_id', array('action'=>'orderpay', 'order_id'=>$this->order_info->order_id)); ?>" class="btn btn-primary"><?php echo $this->translate('立即付款'); ?></a>
                <?php } ?></div>

            <p><?php echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分')."s".$this->translate('秒'), $this->order_info->order_time); ?>&nbsp;&nbsp;<span class="black">订单创建</span></p>
            <?php if($this->order_info->pay_time != '') { ?>
                <p><?php echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分')."s".$this->translate('秒'), $this->order_info->pay_time); ?>&nbsp;&nbsp;<span class="black">订单已付款 </span></p>
            <?php } ?>
            <?php if($this->order_info->express_time != '') { ?>
                <p><?php echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分')."s".$this->translate('秒'), $this->order_info->express_time); ?>&nbsp;&nbsp;<span class="black">订单已发货</span></p>
            <?php } ?>
            <?php if($this->order_info->finish_time != '') { ?>
                <p><?php echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分')."s".$this->translate('秒'), $this->order_info->finish_time); ?>&nbsp;&nbsp;<span class="black">订单完成</span></p>
            <?php } ?>
            <p style=" margin-top:10px; margin-bottom:18px;"><button class="btn btn-primary" onclick="location.href='<?php echo $this->url('frontorder/default/order_page', array('action'=>'index', 'page'=>$this->page, 'order_state'=>$this->order_state)); ?>'" type="button"><i class=" icon-arrow-left icon-white"></i> <?php echo $this->translate('返回订单列表'); ?></button></p>
        </div>
        <?php if($this->order_log) { ?>
            <div>
                <table class="simple form">
                    <tr>
                        <th class="tl" style="padding-left: 20px;" colspan=2><?php echo $this->translate('订单取消说明'); ?>：</th>
                    </tr>
                    <?php foreach($this->order_log as $log_value) { ?>
                        <tr><td class="label"><?php echo $log_value['log_user']; ?>：</td><td><?php echo $this->escapeHtml($log_value['state_info']); ?></td></tr>
                    <?php } ?>
                </table>
            </div>
        <?php } ?>

        <?php if ($this->delivery_address) { ?>
        <div>
            <table class="simple form">
                <tr>
                    <th class="tl" style="padding-left: 20px;" colspan=2><?php echo $this->translate('收货人信息'); ?>：</th>
                </tr>
                <tr><td class="label"><?php echo $this->translate('收货人'); ?>：</td><td><?php echo $this->escapeHtml($this->delivery_address->delivery_name); ?></td></tr>
                <tr><td class="label"><?php echo $this->translate('地址'); ?>：</td>
                    <td>
                        <?php
                        echo $this->escapeHtml($this->delivery_address->region_address).'<br>';
                        $region_array = @explode(' ', $this->delivery_address->region_info);
                        $region_array = array_reverse($region_array);
                        echo $this->escapeHtml(implode(', ', $region_array));
                        ?>
                    </td>
                </tr>
                <tr><td class="label"><?php echo $this->translate('邮编'); ?>：</td><td><?php if ($this->delivery_address->zip_code) echo $this->escapeHtml($this->delivery_address->zip_code); ?></td></tr>
                <tr><td class="label"><?php echo $this->translate('手机'); ?>：</td><td><?php if ($this->delivery_address->mod_phone) echo $this->escapeHtml($this->delivery_address->mod_phone); ?></td></tr>
                <tr><td class="label"><?php echo $this->translate('电话'); ?>：</td><td><?php if ($this->delivery_address->tel_phone) echo $this->escapeHtml($this->delivery_address->tel_phone); ?></td></tr>
                <?php if(!empty($this->delivery_address->express_time_info)) { ?>
                    <tr><td class="label"><?php echo $this->translate('送货时间'); ?>：</td><td><?php echo $this->escapeHtml($this->delivery_address->express_time_info); ?></td></tr>
                <?php } ?>
            </table>
        </div>
        <?php } ?>

        <div>
            <table class="simple form">
                <tr>
                    <th class="tl" style="padding-left: 20px;" colspan=2><?php echo $this->translate('支付及配送方式'); ?>：</th>
                </tr>
                <tr><td class="label"><?php echo $this->translate('支付方式'); ?>：</td><td><?php echo $this->order_info->pay_name; ?></td></tr>
                <?php if ($this->order_info->pay_code == 'xxzf' and $this->order_info->pay_certification != '') { ?>
                    <tr><td class="label"><?php echo $this->translate('支付证明'); ?>：</td><td><?php echo $this->escapeHtml($this->order_info->pay_certification); ?></td></tr>
                <?php } ?>
                <?php if ($this->delivery_address) { ?>
                <tr><td class="label"><?php echo $this->translate('物流公司'); ?>：</td><td><?php echo $this->delivery_address->express_name; ?></td></tr>
                <tr><td class="label"><?php echo $this->translate('运费'); ?>：</td><td><?php echo $this->order_info->currency_symbol . $this->order_info->express_fee; ?></td></tr>
                <?php if ($this->delivery_address->express_number != '') { ?>
                    <tr><td class="label"><?php echo $this->translate('快递单号'); ?>：</td><td><?php echo $this->delivery_address->express_number; ?>
                        </td>
                    </tr>
                  <?php } ?>
                <?php } ?>
            </table>
        </div>
        <?php if (isset($this->order_info->order_message) and !empty($this->order_info->order_message)) { ?>
            <div>
                <table class="simple form">
                    <tr>
                        <th class="tl" style="padding-left: 20px;" colspan=2><?php echo $this->translate('买家留言'); ?>：</th>
                    </tr>
                    <tr><td class="label"><?php echo $this->translate('留言信息'); ?>：</td><td><?php echo $this->escapeHtml($this->order_info->order_message); ?></td></tr>
                </table>
            </div>
        <?php } ?>
        <?php if (isset($this->order_info->invoice_content) and !empty($this->order_info->invoice_content)) { ?>
            <div>
                <table class="simple form">
                    <tr>
                        <th class="tl" style="padding-left: 20px;" colspan=2><?php echo $this->translate('购物发票'); ?>：</th>
                    </tr>
                    <tr><td class="label"><?php echo $this->translate('发票信息'); ?>：</td><td><?php echo $this->escapeHtml($this->order_info->invoice_content); ?></td></tr>
                </table>
            </div>
        <?php } ?>

        <div>
            <h2 class="mt20"><?php echo $this->translate('商品清单'); ?></h2>
            <table class="simple mt10">
                <tr>
                    <th colspan="2"><?php echo $this->translate('商品名称'); ?></th>
                    <th width="140"><?php echo $this->translate('商品货号'); ?></th>
                    <th width="100"><?php echo $this->translate('规格'); ?></th>
                    <th width="80"><?php echo $this->translate('商品价格'); ?></th>
                    <th width="40"><?php echo $this->translate('数量'); ?></th>
                    <th width="80"><?php echo $this->translate('小计'); ?></th>
                </tr>

                <?php foreach ($this->order_goods as $goods_key => $goods_value) { ?>

                    <tr class="<?php echo $goods_key%2==1 ? 'even' : 'odd'; ?>">
                        <td width="40"><a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['class_id'])); ?>" target="_blank"><img src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($goods_value['goods_image'])); ?>" width="40"></a></td>
                        <td><a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['class_id'])); ?>" target="_blank"><?php echo $this->escapeHtml($goods_value['goods_name']); ?></a>
                        </td>
                        <td><?php echo $this->escapeHtml($goods_value['goods_item']);?></td>
                        <td>
                            <?php
                            if($goods_value['goods_extend_info']) {
                                echo $goods_value['goods_extend_info'];
                            } else {
                                echo $this->translate('无');
                            }
                            ?>
                        </td>
                        <td><?php echo $this->order_info->currency_symbol . $goods_value['goods_shop_price'] . $this->order_info->currency_unit; ?></td>
                        <td><?php echo $goods_value['buy_num']; ?></td>
                        <td><?php echo $this->order_info->currency_symbol . $goods_value['goods_amount'] . $this->order_info->currency_unit; ?></td>
                    </tr>
                <?php } ?>
            </table>
        </div>

        <div class="box p10 tr order-total">
            <div class="pb10">
                <?php if($this->order_info->goods_weight_amount > 0) { ?>
                    <p><?php echo $this->translate('商品总重量'); ?>：<?php echo $this->order_info->goods_weight_amount.$this->translate('千克'); ?></p>
                <?php } ?>
                <p><?php echo $this->translate('商品总金额'); ?>：<?php echo $this->order_info->currency_symbol . $this->order_info->goods_amount; ?></p>
                <p>+ <?php echo $this->translate('运费'); ?>：<?php echo $this->order_info->currency_symbol . $this->order_info->express_fee; ?></p>
                <p>+ <?php echo $this->translate('支付手续费'); ?>：<?php echo $this->order_info->currency_symbol . $this->order_info->pay_fee; ?></p>
                <p>- <?php echo $this->translate('购买优惠'); ?>：<?php echo $this->order_info->currency_symbol . $this->order_info->buy_pre_fee; ?></p>
                <p>- <?php echo $this->translate('会员优惠'); ?>：<?php echo $this->order_info->currency_symbol . $this->order_info->user_pre_fee; ?></p>
                <?php if($this->order_info->coupon_pre_fee > 0) { ?>
                <p>- <?php echo $this->translate('优惠券优惠'); ?>：<?php echo $this->order_info->currency_symbol . $this->order_info->coupon_pre_fee; ?></p>
                <?php } ?>
                <?php if(isset($this->order_info->integral_buy_price) and $this->order_info->integral_buy_price > 0) { ?>
                    <p>- <?php echo $this->translate('积分购买'); ?>：<?php echo $this->order_info->currency_symbol . $this->order_info->integral_buy_price; ?></p>
                <?php } ?>
                <?php
                if(isset($this->order_amount_log) and !empty($this->order_amount_log)) {
                    foreach($this->order_amount_log as $amount_log) {
                        ?>
                        <p><?php echo $amount_log['order_edit_amount_type']; ?> <?php echo $amount_log['order_edit_amount_info']; ?>：<?php echo $this->order_info->currency_symbol.ltrim($amount_log['order_edit_number'], '-'); ?></p>
                    <?php } } ?>

            </div>
            <div class="t-line pt10 total">
                <?php echo $this->translate('订单总金额'); ?>：<b><?php echo $this->order_info->currency_symbol . $this->order_info->order_amount . $this->order_info->currency_unit; ?></b>
                <?php if ($this->order_info->integral_num > 0) { ?>
                    <br><hr>
                    <?php echo $this->translate('消费积分'); ?>(<?php if ($this->order_info->integral_rule_info != '') {echo $this->order_info->integral_rule_info . ',&nbsp;';} echo $this->translate('交易完成确认收货后才得到积分'); ?>)：<b><?php echo $this->order_info->integral_num; ?><?php echo $this->translate('积分'); ?></b>
                <?php } ?>
                <?php if ($this->order_info->integral_type_2_num > 0) { ?>
                    <br>
                    <?php echo $this->translate('等级积分'); ?>(<?php if ($this->order_info->integral_type_2_num_rule_info != '') {echo $this->order_info->integral_type_2_num_rule_info . ',&nbsp;';} echo $this->translate('交易完成确认收货后才得到积分'); ?>)：<b><?php echo $this->order_info->integral_type_2_num; ?><?php echo $this->translate('积分'); ?></b>
                <?php } ?>
            </div>
        </div>

        <div style="margin-top: 20px;">
            <form method="post" onsubmit="return order_confirm();">
                <input name="order_finish" id="order_finish" type="hidden" value="true" />
                <p align="center"><button class="btn btn-primary btn-large" type="submit"><i class="icon-ok icon-white"></i> <?php echo $this->translate('确认收货'); ?></button></p>
            </form>
        </div>
        <script>
            function order_confirm() {
                if(window.confirm('<?php echo $this->translate('您确定要确认收货吗？'); ?>')) {
                    return true;
                } else {
                    return false;
                }
            }
        </script>
        <?php if (isset($this->express_state_array)) { ?>
            <div>
                <table class="simple form">
                    <tr>
                        <th class="tl" style="padding-left: 20px;" colspan=2><?php echo $this->translate('物流实时信息'); ?></th>
                    </tr>
                    <tr><td colspan="2">
                            <?php if(isset($this->express_state_array['api_type']) and !empty($this->express_state_array['api_type'])) { ?>
                                <p><?php echo $this->express_state_array['content']; ?></p>
                            <?php } ?>
                        </td>
                    </tr>
                </table>
            </div>
        <?php } ?>
    </div>
</div>
